﻿package skyExt
{

    public class SkyMath extends Object
    {
        public static var sinArr:Array= new Array(0, 175, 349, 523, 698, 872, 1045, 1219, 1392, 1564,
			1736, 1908, 2079, 2250, 2419, 2588, 2756, 2924, 3090, 3256, 3420, 3584, 
			3746, 3907, 4067, 4226, 4384, 4540, 4695, 4848, 5000, 5150, 5299, 5446,
			5592, 5736, 5878, 6018, 6157, 6293, 6428, 6561, 6691, 6820, 6947, 7071, 
			7193, 7314, 7431, 7547, 7660, 7771, 7880, 7986, 8090, 8192, 8290, 8387,
			8480, 8572, 8660, 8746, 8829, 8910, 8988, 9063, 9135, 9205, 9272, 9336, 
			9397, 9455, 9511, 9563, 9613, 9659, 9703, 9744, 9781, 9816, 9848, 9877, 
			9903, 9925, 9945, 9962, 9976, 9986, 9994, 9998, 10000);;

        public static function my_arcsin(angle:uint) : uint
        {
            var a:uint = 0;
            var b:uint = 90;
            var c:uint = 45;
            while (c > 0)
            {
                if (sinArr[c + a] < angle)
                {
                    a +=c;
                }
                else if (sinArr[c + a] == angle)
                {
                    return c + a;
                }
                b -=c;
                c = b / 2;
            }
            if (angle - sinArr[a] > sinArr[(a + 1)] - angle)
            {
                a +=1;
            }
            return a;
        }// end function

        public static function my_sqrt(dis:uint) : uint
        {
            var a:uint = 0;
            if (dis == 1 || dis == 0)
            {
                return dis;
            }
            var b:uint = dis;
            var c:uint = 0;
            while ((c + 1) < b)
            {
                
                a = 0;
                a = c + (b - c) / 2;
                if (a > dis / a)
                {
                    b = a;
                    continue;
                }
                c = a;
            }
            return c;
        }// end function

    }
}
